package com.pashanhoo.netty.nio;

import java.nio.IntBuffer;

/**
 * @author 胡庆安
 * @version V1.0
 * @Package com.pashanhoo.netty.nio
 * @date 2020/11/4 16:13
 * @Copyright © 2010-2020 爬山虎科技（扬州）股份有限公司
 */
public class BasicBuffer {
    public static void main(String[] args) {
        IntBuffer intBuffer = IntBuffer.allocate(5);
        for (int i=0;i<intBuffer.capacity();i++){
            intBuffer.put(i*2);
        }

        //buffer的读写切换
        intBuffer.flip();
        //从buffer中读取数据
        while (intBuffer.hasRemaining()){
            System.out.println(intBuffer.get());
        }
    }
}
